package com.boxfishedu.foreignkey.service;

import com.boxfishedu.foreignkey.entity.Subject;
import com.boxfishedu.foreignkey.entity.jpa.SubjectJpaRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * Created by lzx on 16/3/9.
 */
@Service
public class SubjectService {

    @Autowired
    SubjectJpaRepository subjectJpaRepository;

    @Transactional
    public Subject save(Subject subject) {
        return subjectJpaRepository.save(subject);
    }

    @Transactional
    public Subject save(String name) {
        Subject subject = new Subject();
        subject.setName(name);
        return save(subject);
    }
}
